package com.jydd.mybroadcastreceiverstudy;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;

public class MyReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Util.showToast(context,"Receive an intent : " + intent.getAction());
        // 静态广播
        if(Util.STATIC_RECEIVER_ACTION.equals(intent.getAction())){
            Util.showToast(context, "我是静态广播!!!");
        } else if(Util.DYNAMIC_RECEIVER_ACTION.equals(intent.getAction())){
            Util.showToast(context, "我是动态广播!!!");
            Intent intent1 = new Intent();
            intent1.setClass(context, TestActivity.class);
            intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent1);
        } else if(WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())){
            Util.showToast(context,intent.getAction());
            Intent intent_re = new Intent(context, MainActivity.class);
            intent_re.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent_re);
        }

    }
}
